package com.niit.TopN.ProvinceTopN;

import com.niit.bean.ProvinceBean;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class ProvinceTopNReducer  extends Reducer<ProvinceBean, NullWritable,ProvinceBean, NullWritable> {
    @Override
    protected void reduce(ProvinceBean key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        int num = 0;//统计循环次数
        for(NullWritable value :values){
            if (num<10){
                context.write(key,value);
                num++;
            }else {
                return;
            }

        }


    }
}
